#ifndef YHAIDA_SOCKET_H
#define YHAIDA_SOCKET_H
#include "../base/Utils.h"
#include "InetAddress.h"
#include "SocketsOps.h"
namespace yhaida
{
    class Socket : Utils::nocapyable
    {
    public:
        explicit Socket(int sockfd) : _fd(sockfd) {}
        ~Socket() { sockets::close(_fd); }

        int fd() { return _fd; }

        void bind(const InetAddress &);

        void listen();

        int accept(InetAddress *addr);

        void setReuseAdr(bool on);
        void setReusePort(bool on);

        void shutdownWrite();

        void setTcpNoDelay(bool on);

        void setTcpKeepAlive(bool on);
    private:
        const int _fd;
    };
}
#endif